package org.ala.tcp_feign_common.msg.biz;

import org.ala.tcp_feign_common.enums.TcpFeignBizAckTypeEnums;
import org.ala.tcp_feign_common.enums.TcpFeignMessageTypeEnums;
import org.ala.tcp_feign_common.msg.AbstractByteMessage;


/**
 * 业务消息回执
 * 
 * [0x06 | 消息总长(4字节) | 消息id(8字节) | 发送消息时间戳(8子节) | 受理状态（1子节）]
 * 
 * @author 骆毅(ala)
 * @date 2024年4月19日
 */
public class BizACKByteMessage extends AbstractByteMessage {
	private static final long serialVersionUID = 1L;
	
	
	/**
	 * 消息id
	 */
	protected long msgId;
	/**
	 * 是否受理
	 * <p>	可能收到消息的server不具备处理消息的能力，此时返回false
	 */
	protected TcpFeignBizAckTypeEnums accept;
	/**
	 * 发送消息时间戳
	 */
	protected long timestamp;
	
	
	public static BizACKByteMessage success(long msgId) {
		BizACKByteMessage msg = new BizACKByteMessage();
		msg.msgId = msgId;
		msg.accept = TcpFeignBizAckTypeEnums.SUCCESS;
		msg.timestamp = System.currentTimeMillis();
		return msg;
	}
	public static BizACKByteMessage faild(long msgId, TcpFeignBizAckTypeEnums type) {
		BizACKByteMessage msg = new BizACKByteMessage();
		msg.msgId = msgId;
		msg.accept = type;
		msg.timestamp = System.currentTimeMillis();
		return msg;
	}
	

	@Override
	public TcpFeignMessageTypeEnums type() {
		return TcpFeignMessageTypeEnums.BIZ_ACK;
	}


	public long getMsgId() {
		return msgId;
	}

	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}
	
	public TcpFeignBizAckTypeEnums getAccept() {
		return accept;
	}
	
	public void setAccept(TcpFeignBizAckTypeEnums accept) {
		this.accept = accept;
	}
	
}
